home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-07 | 5.1 KB | 139 lines | [TEXT/CWIE] |
- // File: LabMaker.h
-
- enum {
- kMaxLabNameLength = 16, // Longest possible lab name
- kMaxFileNameLength = 32, // Longest possible file or path name
- kFullPathLength = 128, // 4 * kMaxFileNameLength
- kMaxLabs = 32, // How many lab files can be open at a time
- kMaxLineLength = 256, // How long of a line will we process
- kStackSize = 16, // How many pushes will we accept
- kMaxFileTypes = 16, // How many file suffixes will we accept
- kMaxCommandLength = 16, // Commands are no longer than 16 characters
- kMaxCommentTypes = 4, // We'll accept up to 4 styles of comments
- kMaxCommentLength = 4 // Maximum numbers of characters in a comment delimeter
- };
-
- enum {
- // return results for FindLab and FindSuffix
- kAllLabs = -2,
- kLabNotFound = -1,
- kSuffixNotFound = -1
- };
-
- enum {
- // Options for "Pop"
- kReplaceLabs = 0,
- kMergeLabs = 1
- };
-
- enum {
- // Options in the command table
- kNoParams = 0, // Don't bother to extract parameters from the string
- kPassComment, // Pass the whole comment to the command (e.g. /* $comment */)
- kPassParams, // Pass only the parameter list to the command
- kPassBuffer // Pass the whole line to the command
- };
-
- struct CommentInfo {
- char commentStart[kMaxCommentLength];
- char commentEnd[kMaxCommentLength];
- short columnOneOnly; // True if this comment delimeter must begin in column 1
- };
-
- typedef struct CommentInfo CommentInfo;
-
- struct FileOptions {
- char suffix[kMaxFileNameLength];
- short numCommentTypes;
- char commandChar;
- CommentInfo commentDelimiters[kMaxCommentTypes];
- };
-
- typedef struct FileOptions FileOptions;
-
- struct LabInfo {
- short isActive;
- char labName[kMaxLabNameLength];
- char directoryName[kMaxFileNameLength];
- FILE* file;
- };
-
- typedef struct LabInfo LabInfo;
-
- typedef void (*Command)(char *buffer, short paramStart, short paramEnd, char* filename);
-
- struct CommandEntry {
- char commandName[kMaxCommandLength];
- int uniqueChars;
- Command theCommand;
- unsigned int options;
- };
-
- typedef struct CommandEntry CommandEntry;
-
- struct CurrentState {
- FileOptions *currFileOptions;
- char *currFilename;
- short numLabs;
- LabInfo labs[kMaxLabs];
- short isInclude;
- short skipBlanks; // Should we skip blank lines?
- char buffer[kMaxLineLength]; // A copy of the current buffer, for error
- // reporting purposes
- };
-
- typedef struct CurrentState CurrentState;
-
-
- // --- Prototypes
-
- void Error(char* message, char *buffer, short index, char* fileName);
- void Warning(char* message, char *buffer, short index, char* fileName);
- int GetOrMakeDirectory(char *path, short isFullPath);
- FILE* GetOrMakeFile(char* fileName, char *path, short isFullPath);
- int CopyFile(char* sourceFileName, char *sourcePath, char* copyPath, short isFullPath);
-
- static char *MakeLower(char* buffer);
-
- int ProcessUserFile(char *filename);
- void ProcessLine(char *buffer, int *inComment, char* filename);
- void RemoveComment(char *buffer, short *index, short startOfComment);
- CommandEntry *FindCommand(char *possibleCommand);
- short FindLab(char* labName);
- short FindSuffix(char* suffix);
- char *GetKeyword(char* keyword, char* buffer, short *index, char* result);
- char *GetNextSubstring(char* buffer, short *index, char *result, short allowQuotes);
- char *GetLabName(char* buffer, short *index, char *result);
- char *GetFileName(char* buffer, short *index, char *result);
- char *GetDirectoryName(char* buffer, short *index, char *result);
- char *FindCommentStart(char *buffer, short *index, short *startOffset, short *commentKind);
- char *FindCommentEnd(char *buffer, short *index, short *endOffset, short commentKind);
- char *SkipWhitespace(char *buffer, short *index);
- void DistributeLine(char *buffer);
- void GetFileOptions(char *filename);
- void OpenLab(short labID);
- void CloseLab(short labID);
- void CloseAllLabs(void);
- void Push(void);
- void Pop(short options);
- void CopyOrSkip(char *buffer, short paramStart, short paramEnd, char* filename, short activate);
- void ClearFileOption(FileOptions *oneOption);
-
- void DoInsert(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoComment(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoCreate(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoInclude(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoCopy(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoSkip(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoInsert(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoPush(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoPop(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoSuffix(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoDelimiter(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoReset(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoOnly(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoNot(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoEndSuffix(char *buffer, short paramStart, short paramEnd, char* filename);
- void DoSkipBlanks(char *buffer, short paramStart, short paramEnd, char* filename);
-
-